home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / oobr / br-info.el < prev    next >
Encoding:
Text File  |  1995-04-28  |  7.4 KB  |  201 lines

  1. ;;!emacs
  2. ;;
  3. ;; FILE:         br-info.el
  4. ;; SUMMARY:      Support routines for Info file hierarchy browsing.
  5. ;; USAGE:        GNU Emacs Lisp Library
  6. ;; KEYWORDS:     docs, help, hypermedia
  7. ;;
  8. ;; AUTHOR:       Bob Weiner
  9. ;; ORG:          Motorola Inc.
  10. ;;
  11. ;; ORIG-DATE:     7-Dec-89
  12. ;; LAST-MOD:     17-Apr-95 at 17:35:32 by Bob Weiner
  13. ;;
  14. ;; Copyright (C) 1989-1995  Free Software Foundation, Inc.
  15. ;; See the file BR-COPY for license information.
  16. ;;
  17. ;; This file is part of the OO-Browser.
  18. ;;
  19. ;; DESCRIPTION:  
  20. ;;
  21. ;;   See 'info-class-def-regexp' for regular expression that matches class
  22. ;;   definitions.
  23. ;;            
  24. ;; DESCRIP-END.
  25.  
  26. ;;; ************************************************************************
  27. ;;; Other required Elisp libraries
  28. ;;; ************************************************************************
  29.  
  30. (require 'br-lib)
  31.  
  32. ;;; ************************************************************************
  33. ;;; User visible variables
  34. ;;; ************************************************************************
  35.  
  36. (defvar info-lib-search-dirs nil
  37.   "List of directories below which Info Library source files are found.
  38. Subdirectories of Library source are also searched.  A Library is a stable
  39. group of classes.")
  40.  
  41. (defvar info-sys-search-dirs nil
  42.   "List of directories below which Info System source files are found.
  43. Subdirectories of System source are also searched.  A System class is one
  44. that is not yet reusable and is likely to change before release.")
  45.  
  46. (defconst info-narrow-view-to-class t
  47.  "*Non-nil means narrow buffer to just the matching class definition when displayed.")
  48.  
  49. ;;; ************************************************************************
  50. ;;; Internal functions
  51. ;;; ************************************************************************
  52.  
  53. (defun info-find-nd (filename node edit)
  54.   "Show (FILENAME)NODE in current window.
  55. If EDIT is non-nil, NODE is made editable."
  56.   (if (string-match "-[1-9][0-9]*$" filename)
  57.       (setq filename (substring filename 0 (match-beginning 0))) )
  58.   (Info-find-node filename node t)
  59.   (if edit (let ((Info-enable-edit t))
  60.          (Info-edit))))
  61.  
  62. (defun info-get-classes-from-source (filename &rest ignore)
  63.   "Scans FILENAME and returns cons of class list with parents-class alist.
  64. Handles multiple inheritance.  Assumes file existence and readability have
  65. already been checked."
  66.   (let ((no-kill (get-file-buffer filename))
  67.     classes class parents parent-cons)
  68.     (if no-kill
  69.     (set-buffer no-kill)
  70.       (funcall br-view-file-function filename))
  71.     (save-restriction
  72.       (save-excursion
  73.     (widen)
  74.     (goto-char (point-min))
  75.     (while (re-search-forward info-class-def-regexp nil t)
  76.       (setq class (buffer-substring (match-beginning 1) (match-end 1))
  77.         parent-cons
  78.         (cons 
  79.           (if (looking-at info-parent-regexp)
  80.               (list (buffer-substring
  81.                  (match-beginning 1)
  82.                  (match-end 1))))
  83.           class)
  84.         classes (cons class classes)
  85.         parents (cons parent-cons parents)))))
  86.     (or no-kill (kill-buffer (current-buffer)))
  87.     (cons classes (delq nil parents))))
  88.  
  89. (defun info-get-parents-from-source (filename class-name)
  90.   "Scan source in FILENAME and return list of parents of CLASS-NAME.
  91. Assume file existence has already been checked."
  92.     (or (null class-name)
  93.     (let ((br-view-file-function 'br-insert-file-contents))
  94.       (car (car (br-rassoc
  95.               class-name
  96.               (cdr (info-get-classes-from-source filename))))))))
  97.  
  98. (defun info-select-path (paths-htable-elt &optional feature-p)
  99.   "Select proper pathname from PATHS-HTABLE-ELT based upon value of optional FEATURE-P.
  100. Selection is between path of class definition and path for features associated
  101. with the class."
  102.   (cdr paths-htable-elt))
  103.  
  104. (defun info-set-case (type)
  105.   "Return string TYPE identifier for use as a class name."
  106.   type)
  107.  
  108. (defun info-set-case-type (class-name)
  109.   "Return string CLASS-NAME for use as a type identifier."
  110.   class-name)
  111.  
  112. (defun info-to-class-end ()
  113.   "Assuming point is at start of node, move to start of line after end of node."
  114.   (interactive)
  115.   (skip-chars-forward "  \t\n")
  116.   (if (re-search-forward "[ ]" nil t)
  117.       (beginning-of-line)
  118.     (goto-char (point-max))))
  119.  
  120. (defun info-to-comments-begin ()
  121.   "Skip back from current point past any preceding Info comments."
  122.   (skip-chars-forward "  \t\n"))
  123.  
  124. ;;; ************************************************************************
  125. ;;; Internal variables
  126. ;;; ************************************************************************
  127.  
  128. (defconst info-class-name-before
  129.   " ?[\n][\n\t ]*.*Node:[ \t]+"
  130.   "Regexp preceding the class name in a class definition.")
  131.  
  132. (defconst info-identifier-chars "-_()a-zA-Z0-9 "
  133.   "String of chars and char ranges that may be used within an Info identifier.")
  134.  
  135. (defconst info-identifier (concat "\\([a-zA-Z0-9()][" info-identifier-chars "]*\\)")
  136.   "Regular expression matching an Info identifier.")
  137.  
  138. (defconst info-class-name-after
  139.   "[\t,\n]+"
  140.   "Regexp following the class name in a class definition.")
  141.  
  142. (defconst info-class-def-regexp
  143.   (concat info-class-name-before info-identifier info-class-name-after)
  144.   "Regular expression used to match to class definitions in source text.
  145. Class name identifier is grouped expression 1.")
  146.  
  147. (defconst info-parent-regexp
  148.   (concat ".*Up:[ \t]+" info-identifier)
  149.   "Regular expression whose grouping number 1 matches Info parent identifier.")
  150.  
  151. (defconst info-lang-prefix "info-"
  152.  "Prefix string that starts \"br-info.el\" symbol names.")
  153.  
  154. (defconst info-file-dir-regexp "^[^.~#].*[^.~#]$"
  155.   "Regexp that ignores extraneous non-source files and directories.")
  156.  
  157. (defconst info-src-file-regexp ".$"
  158.   "Regular expression matching a unique part of Info source.")
  159.  
  160. (defvar info-children-htable nil
  161.   "Htable whose elements are of the form: (LIST-OF-CHILD-CLASSES . CLASS-NAME).
  162. Used to traverse Info inheritance graph.  'br-build-children-htable' builds
  163. this list.")
  164. (defvar info-parents-htable nil
  165.   "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
  166. Used to traverse Info inheritance graph.  'br-build-parents-htable' builds
  167. this list.")
  168. (defvar info-paths-htable nil
  169.   "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . FILE-PATH).
  170. FILE-PATH gives the location of classes found in LIST-OF-CLASS-NAMES.
  171. 'br-build-paths-htable' builds this list.")
  172.  
  173.  
  174. (defvar info-lib-parents-htable nil
  175.   "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
  176. Only classes from stable software libraries are used to build the list.")
  177. (defvar info-lib-paths-htable nil
  178.   "Htable whose elements are of the form: (LIST-OF-CLASS-NAMES . FILE-PATH).
  179. FILE-PATH gives the location of classes found in LIST-OF-CLASS-NAMES.
  180. Only classes from stable software libraries are used to build the list.")
  181.  
  182. (defvar info-sys-parents-htable nil
  183.   "Htable whose elements are of the form: (LIST-OF-PARENT-CLASSES . CLASS-NAME).
  184. Only classes from systems that are likely to change are used to build the list.")
  185. (defvar info-sys-paths-htable nil
  186.   "Alist whose elements are of the form: (LIST-OF-CLASS-NAMES . FILE-PATH).
  187. FILE-PATH gives the location of classes found in LIST-OF-CLASS-NAMES.
  188. Only classes from systems that are likely to change are used to build the
  189. list.")
  190.  
  191. (defvar info-lib-prev-search-dirs nil
  192.   "Used to check if 'info-lib-classes-htable' must be regenerated.")
  193. (defvar info-sys-prev-search-dirs nil
  194.   "Used to check if 'info-sys-classes-htable' must be regenerated.")
  195.  
  196. (defvar info-env-spec nil
  197.   "Non-nil value means Environment specification has been given but not yet built.
  198. Nil means current Environment has been built, though it may still require updating.")
  199.  
  200. (provide 'br-info)
  201.